package eu.telecombretagne.rsm.protocol.test;

import eu.telecombretagne.rsm.base.entity.AltBitReceiverEntity;
import eu.telecombretagne.rsm.base.entity.AppReceiverEntity;
import eu.telecombretagne.rsm.base.entity.NetworkReaderReceiverEntity;
import eu.telecombretagne.rsm.base.entity.NetworkWriterReceiverEntity;
import eu.telecombretagne.rsm.base.event.*;
import eu.telecombretagne.rsm.gui.NameConsts;
import eu.telecombretagne.rsm.gui.frames.DesktopFrame;

public class Recepteur {
	
	private NetworkReaderReceiverEntity networkReaderReceiverEntity;
	private NetworkWriterReceiverEntity networkWriterReceiverEntity;
	private AppReceiverEntity appReceiverEntity;
	private AltBitReceiverEntity altBitReceiverEntity;
	
	public Recepteur(){
		EventChannel ec = new EventChannel ();
		
		networkReaderReceiverEntity = new NetworkReaderReceiverEntity(ec);
		networkReaderReceiverEntity.start();

		networkWriterReceiverEntity = new NetworkWriterReceiverEntity(ec);
		networkWriterReceiverEntity.start();
		
		try {
			Thread.sleep (10);
		} catch (InterruptedException ie) {
			DesktopFrame.writeLogError(NameConsts.RECEPTEURMAIN + ie);
			System.exit(1);
		}
		
		appReceiverEntity = new AppReceiverEntity(ec);
		appReceiverEntity.start();
		
		altBitReceiverEntity = new AltBitReceiverEntity(ec);
		altBitReceiverEntity.start();
	}
	
	public void stopRecepteur(){
		networkReaderReceiverEntity.stop();
		networkWriterReceiverEntity.stop();
		appReceiverEntity.stop();
		altBitReceiverEntity.stop();
	}
}